package com.conf;

import org.springframework.context.annotation.Configuration;




@Configuration
public class ShiroConfiguration {
	
//	@Bean(name = "lifecycleBeanPostProcessor")
//    public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
//        return new LifecycleBeanPostProcessor();
//    }
//
//	@Bean(name = "hashedCredentialsMatcher")
//	public HashedCredentialsMatcher hashedCredentialsMatcher() {
//		HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher();
//		credentialsMatcher.setHashAlgorithmName("MD5");
//		credentialsMatcher.setHashIterations(2);
//		credentialsMatcher.setStoredCredentialsHexEncoded(true);
//		return credentialsMatcher;
//	}
//
//	@Bean(name = "shiroRealm")
//	@DependsOn("lifecycleBeanPostProcessor")
//    public UserRealm shiroRealm() {
//		UserRealm realm = new UserRealm();
//		realm.setCredentialsMatcher(hashedCredentialsMatcher());
//        return realm;
//    }
//
//	@Bean(name = "ehCacheManager")
//	@DependsOn("lifecycleBeanPostProcessor")
//	public EhCacheManager ehCacheManager(){
//		EhCacheManager ehCacheManager = new EhCacheManager();
//		return ehCacheManager;
//	}
//
//	@Bean(name = "securityManager")
//	public org.apache.shiro.mgt.SecurityManager securityManager(){
//		DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//		securityManager.setRealm(shiroRealm());
//		securityManager.setCacheManager(ehCacheManager());
//		return securityManager;
//	}
//
//	@Bean(name = "shiroFilter")
//	public ShiroFilterFactoryBean shiroFilterFactoryBean(){
//		ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
//		shiroFilterFactoryBean.setSecurityManager(securityManager());
//
//		Map<String, Filter> filters = new LinkedHashMap<String, Filter>();
//		LogoutFilter logoutFilter = new LogoutFilter();
//		logoutFilter.setRedirectUrl("/login");
//		filters.put("logout", logoutFilter);
//		shiroFilterFactoryBean.setFilters(filters);
//
//		Map<String, String> filterChainDefinitionManager = new LinkedHashMap<String, String>();
////		filterChainDefinitionManager.put("/logout", "logout");
////		filterChainDefinitionManager.put("/user/**", "authc,roles[user]");
////		filterChainDefinitionManager.put("/shop/**", "authc,roles[shop]");
////		filterChainDefinitionManager.put("/admin/**", "authc,roles[admin]");
//		filterChainDefinitionManager.put("/**", "anon");
//
//		shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionManager);
//		shiroFilterFactoryBean.setLoginUrl("/login");
//		shiroFilterFactoryBean.setSuccessUrl("/");
//		shiroFilterFactoryBean.setUnauthorizedUrl("/403");
//
//		return shiroFilterFactoryBean;
//	}
//
//	@Bean
//	@ConditionalOnMissingBean
//    public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
//        DefaultAdvisorAutoProxyCreator daap = new DefaultAdvisorAutoProxyCreator();
//        daap.setProxyTargetClass(true);
//        return daap;
//    }
//
//	@Bean
//    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor() {
//        AuthorizationAttributeSourceAdvisor aasa = new AuthorizationAttributeSourceAdvisor();
//        aasa.setSecurityManager(securityManager());
//        return aasa;
//    }
//
//	@Bean(name = "shiroDialect")
//	public ShiroDialect shiroDialect(){
//		return new ShiroDialect();
//	}
}